home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 009a / snpd0493.zip / CCTRAP.ASM < prev    next >
Assembly Source File  |  1993-04-05  |  2KB  |  65 lines

  1.         PAGE ,132
  2.  
  3. ;  Install a custom Interrupt 23 (Ctrl-C exception) handler
  4. ;
  5. ;  Public domain by Bob Stout
  6. ;
  7. ;  Requires MASM 5.1 or later or equivalent
  8. ;
  9. ;  Assemble with:       MASM /Mx /z ...
  10. ;                       TASM /jMASM /mx /z ...
  11.  
  12.  
  13. %       .MODEL  memodel,C               ;Add model support via command
  14.                                         ;line macros, e.g.
  15.                                         ;MASM /Dmemodel=LARGE
  16.  
  17.         .DATA?
  18. _origvec        dd      ?
  19. _newvec         dd      ?
  20.  
  21.         .CODE
  22.  
  23. ;
  24. ;  This is our actual ISR
  25. ;
  26.  
  27. myint23:
  28.         call    dword PTR _newvec       ;call our handler
  29.         iret
  30.  
  31. ;
  32. ;  Call this to install  our ISR
  33. ;
  34.  
  35. ins23   PROC    USES AX BX DS ES, offs:WORD, segm:WORD
  36.         mov     ax,3523h                ;get old vector...
  37.         int     21h
  38.         mov     word PTR _origvec,bx
  39.         mov     word PTR _origvec+2,es  ;...and save it
  40.         mov     ax,offs                 ;load handler offset...
  41.         mov     word PTR _newvec,ax
  42.         mov     ax,segm                 ; & segment into _newvec
  43.         mov     word PTR _newvec+2,ax
  44.         push    cs                      ;get myint23 segment in DS
  45.         pop     ds
  46.         mov     dx, OFFSET myint23      ;install myint23 in int 23h
  47.         mov     ax,2523h
  48.         int     21h
  49.         ret
  50. ins23   ENDP
  51.  
  52. ;
  53. ;  Call this to uninstall our ISR
  54. ;
  55.  
  56. redo23  PROC    USES AX BX DS
  57.         mov     dx, word PTR _origvec   ;restore original vector
  58.         mov     ds, word PTR _origvec+2
  59.         mov     ax,2523h
  60.         int     21h
  61.         ret
  62. redo23  ENDP
  63.  
  64.         end
  65.